package freakin.wify;

import java.util.List;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiManager;
import android.util.Log;

public class WifiScanReceiver extends BroadcastReceiver {
	
	private static final String TAG = "WiFiScanReceiver";
	
	private WifiService wifiService;
	
	private NetworkManager networkManager;

	public WifiScanReceiver(WifiService ws, NetworkManager networkManager) {
		super();
		wifiService = ws;
		this.networkManager = networkManager;
	}
	
	public void onReceive(Context context, Intent intent) {
		
		if (intent.getAction().equals(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION) ) {
			List<ScanResult> results = wifiService.wifi.getScanResults();
			
			Log.d(TAG, "received wifi scan results");
			networkManager.feedNewScanResults(results);

		}

	}

}
